package com.haixiaoke.saas.house.mapper;

import com.haixiaoke.saas.house.domain.House;
import com.haixiaoke.saas.house.domain.HouseStatus;
import com.haixiaoke.saas.order.domain.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 房屋信息Mapper接口
 *
 * @author panda
 * @date 2023-10-18
 */
public interface HouseMapper {
    /**
     * 查询房屋信息
     *
     * @param houseId 房屋信息主键
     * @return 房屋信息
     */
    House selectHouseByHouseId(String houseId);

    /**
     * 查询房屋信息和楼盘楼栋单元
     * @param houseId
     * @return
     */
    House selectHouseInfoByHouseId(String houseId);

    /**
     * 查询房屋信息列表
     *
     * @param house 房屋信息
     * @return 房屋信息集合
     */
    List<House> selectHouseList(House house);


    /**
     * 新增房屋信息
     *
     * @param house 房屋信息
     * @return 结果
     */
    int insertHouse(House house);

    /**
     * 修改房屋信息
     *
     * @param house 房屋信息
     * @return 结果
     */
    int updateHouse(House house);

    /**
     * 删除房屋信息
     *
     * @param houseId 房屋信息主键
     * @return 结果
     */
    int deleteHouseByHouseId(String houseId);

    /**
     * 批量删除房屋信息
     *
     * @param houseIds 需要删除的数据主键集合
     * @return 结果
     */
    int deleteHouseByHouseIds(String[] houseIds);

    /**
     * 根据楼栋id删除房屋
     * @param buildingId
     * @return
     */
    int deleteHouseByBuildingId(Long buildingId);

    /**
     * 统计房间数量
     *
     * @param estateId
     * @param tenantId
     * @return
     */
    int selectHouseByHouseNumber(@Param("estateId") String estateId,@Param("shareFlatType") String shareFlatType, @Param("tenantId") String tenantId);

    /**
     * 统计指定房间状态的数量
     *
     * @param houseState
     * @param onlineRentalType
     * @return
     */
    int selectHouseCountByHouseState(@Param("houseState") String houseState, @Param("houseLeaseState")String houseLeaseState, @Param("houseMaintainState")String houseMaintainState,@Param("onlineRentalType") String onlineRentalType,@Param("shareFlatType") String shareFlatType,@Param("tenantId") String tenantId);

    int softDeleteHouseByHouseIds(String houseId);

    List<House> selectHouseListByInfo(House house);

    HouseStatus selectHouseStatus(House house);

    /**
     * 根据状态、状态类型，插叙房屋数量
     * @param houseState
     * @param houseStateType
     * @return
     */
    int selectHouseNumByHouseState(@Param("houseState") String houseState,@Param("houseStateType") String houseStateType,@Param("tenantId") String tenantId);

    List<House> selectHouseByHouseIdsAndTenantId(House house);

    /**
     * 统计房间数量
     *
     * @param buildingId
     * @param tenantId
     * @return
     */
    int selectHouseByBuildingIdHouseNumber(@Param("buildingId") String buildingId,@Param("shareFlatType") String shareFlatType, @Param("tenantId") String tenantId);

    /**
     * 校验楼盘、单元、楼栋、下的房屋是否存在
     * @param house
     * @return
     */
    int checkHouse(House house);

    /**
     * 房态查询
     * @param house
     * @return
     */
    List<House> conditionList(House house);

    /**
     * 根据房屋id集合查询房屋集合
     * @param houseIds
     * @return
     */
    List<House> selectHouseByHouseIds(List<String> houseIds);

    int updateHouseByDelFlag(String houseId);

    /**
     * 根据租户id查询房屋数量
     * @param tenantId
     * @return
     */
    int countHouseNumByTenantId(String tenantId);

    List<House> selectHousePage(House house);

    /**
     * 短租订单--根据订单入离时间查询房屋数量
     * @param order
     * @return
     */
    int countHouseCountByShortLease(Order order);

    /**
     * 短租订单--根据订单入离时间查询房屋集合
     * @param order
     * @return
     */
    List<House> selectHouseListByShortLease(Order order);

    /**
     * 短租订单--根据订单入离时间查询房屋数量
     * @param order
     * @return
     */
    int countHouseCountByLongLease(Order order);

    /**
     * 长租订单--根据订单入离时间查询房屋集合
     * @param order
     * @return
     */
    List<House> selectHouseListByLongLease(Order order);
}
